<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Add New Contact</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>

<body>
<h3>Enter the New Contact's Details</h3>
<form action="#" method="post">
First Name:<br/>
<input type="text" name="fname" size="30" required class="txt"><br/>
Second Name:<br/>
<input type="text" name="sname" size="30" required class="txt"><br/>
Email:<br/>
<input type="email" name="email" size="30" required class="txt"><br/>
Phone Number:<br/>
<input type="text" name="phone" size="30" required class="txt"><br/><br/>
<input type="submit" name="submit" value="Add Contact" class="sbtns">&emsp;&emsp;&emsp;
<input type="reset" name="Cancel" value="Cancel" class="sbtns">
</form>
<?php
$conn=mysql_connect("localhost","root","") or die("Could not Establish Connection".mysql_error());
$db=mysql_select_db("contacts_ms",$conn) or die("No DB Selected".mysql_error());
if(isset($_POST['submit'])){
	$fname=$_POST['fname'];
	$sname=$_POST['sname'];
	$email=$_POST['email'];
	$phone=$_POST['phone'];
	$qry=mysql_query("INSERT INTO info_contacts(fname,sname,email,phone) VALUES('$fname','$sname','$email','$phone')");
	if(!$qry) $response="Could not Add Contact";
	else $response="Contact added Successfully";
	echo $response;
}
?>
</body>
</html>